<template>
  <div>
    <el-dialog :visible="showdialog" @close="$emit('isDialog', false)">
      <el-form>
        <el-form-item :label-width="labeWidth" label="收款银行">
          <el-input v-model="bankname" :disabled="true" class="input" />
        </el-form-item>
        <el-form-item :label-width="labeWidth" label="转出金额">
          <el-input v-model="coursesection" :disabled="true" class="input" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="$emit('isDialog', false)">取 消</el-button>
        <el-button type="primary" @click="submit">{{ text }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getTeacherDetail, bindCard } from '@/api/teacher'
import { submitMoney } from '@/api/order'
import { checkPhone, checkIdCard, bankCardCheck } from '@/utils/regUtil'

export default {
  name: 'Dialog',
  inject: ['reload'],
  props: {
    showdialog: {
      type: Boolean,
      required: true
    },
    bankname: {
      type: String | null,
      required: true
    },
    coursesection: {
      type: String | Number,
      required: true
    },
    bankid: {
      type: String | Number,
      required: true
    },
    orderid: {
      type: String | Number,
      required: true
    },
    tid: {
      type: String | Number,
      required: true
    },
    type: {
      type: String | Number,
      required: true
    }
  },
  data() {
    return {
      labeWidth: '120px',
      isBind: true,
      text: '',
      tipType: 1 // 1:提款;2:退佣金
    }
  },
  methods: {
    submit() {
      const data = {
        tid: this.$props.tid,
        type: this.$props.type,
        bankInfoId: this.$props.bankid,
        amount: this.$props.coursesection,
        orderId: this.$props.orderid
      }
      submitMoney(data).then(res => {
        if (parseInt(res.code) === 200 && res.message === 'SUCCESS') {
          this.$message.success(Number(this.tipType) === 1 ? '提款成功' : '退佣金成功')
          this.reload()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    changeText(type) {
      this.tipType = type
      this.text = type === 1 ? '提 款' : '退佣金';
    }
  }
}
</script>

<style>

</style>
